package de.koller.million.grid.engine.enc;

import de.koller.million.grid.engine.EngineRoot;
import de.koller.million.grid.engine.player.NPC;
import de.koller.million.grid.frame.enc.EncounterFrame;
import de.koller.aframe.util.thread.ICommand;

public class EncounterCreator implements ICommand {

	private final EngineRoot engineRoot;
	private final PlayerNumber playerNumber;
	private final Tier tier;
	private final Difficulty difficulty;

	private EncounterCreator( EngineRoot engineRoot, PlayerNumber playerNumber, Tier tier, Difficulty difficulty ) {
		this.engineRoot = engineRoot;
		this.playerNumber = playerNumber;
		this.tier = tier;
		this.difficulty = difficulty;
	}

	@Override
	public void handle( Object... params ) {
		Encounter e = new Encounter();
		NPC npc = new NPC( e, engineRoot );
		
		npc.playerStats.healthPoints.joinAdd( "default", 1000 );
		e.npcs.add( npc );
		npc.makeFightReady(); 
		
		engineRoot.setEncounter( e );
		engineRoot.groot.frame.showEncounter();
	}

	
	public static void create( EngineRoot er, PlayerNumber n, Tier t, Difficulty d ) {
		EncounterCreator c = new EncounterCreator( er, n, t, d );
		er.groot.call( c );
	}
	
	public static PlayerNumber createNumber( int n ) {
		return new PlayerNumber( n );
	}
	
	public static Tier createTier( int t ) {
		return new Tier( t );
	}
	
	public static class PlayerNumber {
		private final int playerNumber;

		private PlayerNumber( int playerNumber ) {
			this.playerNumber = playerNumber;
		}

		@Override
		public String toString() {
			return playerNumber + " Spieler";
		}
	}
	
	public static class Tier {
		private final int tier;

		private Tier( int tier ) {
			this.tier = tier;
		}
		
		@Override
		public String toString() {
			return "Tier " + tier;
		}
	}
	
	public enum Difficulty {
		Normal( "Normal" ),
		Hard( "Schwer" ),
		Epic( "Episch" ),
		Legendary( "Legendär" ),
		Dystopian( "Dystopisch" );
		
		private final String rep;

		private Difficulty( String rep ) {
			this.rep = rep;
		}

		@Override
		public String toString() {
			return rep;
		}
	}
}
